﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using lauimini_webform.BLL;

namespace courseWork
{
    public partial class Login : System.Web.UI.Page
    {
        UserService userService;
        public Login()
        {
            userService = new UserService();
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void MyLogin_Click(object sender, EventArgs e)
        {
            
            string userAccount = Request.Form["account"];
            string password = Request.Form["password"];

            int situation = userService.checkUser(userAccount, password);
            if (situation==0)
            {
                Response.Write("<script>alert('用户不存在')</script>");
            }
            if (situation == 1)
            {
                Session["userAccount"] = userAccount;
                Session["password"] = password;
                Response.Write("<script>alert('登入成功');location.href='Home.aspx'</script>");
                return;
            }
            else if (situation==2)
            {
                Response.Write("<script>alert('密码错误')</script>");
            }
           
        }
    }
}